package clientManage

import (
	"hotel_Manager_Api/model/dto"
	"github.com/martini-contrib/encoder"
	"github.com/go-xorm/xorm"
	"hotel_Manager_Api/model/dbModel"
)

func GetClients(page dto.PageCondition,enc encoder.Encoder,db *xorm.Engine) (int,[]byte,error){
	clients := make([]dbModel.ClientInfo,0)
	count,_ := db.Count(dbModel.ClientInfo{})
	db.Desc("id").Limit(page.GetPageSizeAndOffset()).Find(&clients)

	pageResult := page.GetPageResult(int(count),clients)
	return 200,encoder.Must(enc.Encode(pageResult)),nil
}